package de.sabram.upb.specs.serializer;

import com.google.inject.Inject;
import de.sabram.upb.specs.services.LidoGrammarAccess;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.IGrammarAccess;
import org.eclipse.xtext.RuleCall;
import org.eclipse.xtext.nodemodel.INode;
import org.eclipse.xtext.serializer.analysis.GrammarAlias.AbstractElementAlias;
import org.eclipse.xtext.serializer.analysis.GrammarAlias.AlternativeAlias;
import org.eclipse.xtext.serializer.analysis.GrammarAlias.TokenAlias;
import org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynNavigable;
import org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynTransition;
import org.eclipse.xtext.serializer.sequencer.AbstractSyntacticSequencer;

@SuppressWarnings("all")
public class LidoSyntacticSequencer extends AbstractSyntacticSequencer {

	protected LidoGrammarAccess grammarAccess;
	protected AbstractElementAlias match_AttrComp_CHAINSTARTKeyword_2_0_q;
	protected AbstractElementAlias match_AttrDef_ClassParserRuleCall_3_q;
	protected AbstractElementAlias match_AttrSpec_ClassParserRuleCall_4_q;
	protected AbstractElementAlias match_Computation_BOTTOMUPKeyword_1_q;
	protected AbstractElementAlias match_DepClause_DEPENDS_ONKeyword_0_0_or_LessThanSignHyphenMinusKeyword_1_0;
	protected AbstractElementAlias match_Expression_C_FLOATParserRuleCall_1_6_or_C_INTEGERParserRuleCall_1_7_or_STRINGTerminalRuleCall_1_5;
	protected AbstractElementAlias match_SymAttrSpec_TermSpec_SymClassParserRuleCall_0_or_TERMKeyword_0;
	protected AbstractElementAlias match_SymOcc_HEADKeyword_1_4_or_INHKeyword_1_2_or_SYNTKeyword_1_1_or_TAILKeyword_1_5_or_THISKeyword_1_3;
	protected AbstractElementAlias match_SymOcc_IndexParserRuleCall_1_0_1_q;
	protected AbstractElementAlias match_SymbolRef_IndexParserRuleCall_1_0_1_q;
	protected AbstractElementAlias match_SymbolRef_IndexParserRuleCall_1_1_1_q;
	protected AbstractElementAlias match_SyntUnit_DollarSignKeyword_1_0_q;
	
	@Inject
	protected void init(IGrammarAccess access) {
		grammarAccess = (LidoGrammarAccess) access;
		match_AttrComp_CHAINSTARTKeyword_2_0_q = new TokenAlias(false, true, grammarAccess.getAttrCompAccess().getCHAINSTARTKeyword_2_0());
		match_AttrDef_ClassParserRuleCall_3_q = new TokenAlias(false, true, grammarAccess.getAttrDefAccess().getClassParserRuleCall_3());
		match_AttrSpec_ClassParserRuleCall_4_q = new TokenAlias(false, true, grammarAccess.getAttrSpecAccess().getClassParserRuleCall_4());
		match_Computation_BOTTOMUPKeyword_1_q = new TokenAlias(false, true, grammarAccess.getComputationAccess().getBOTTOMUPKeyword_1());
		match_DepClause_DEPENDS_ONKeyword_0_0_or_LessThanSignHyphenMinusKeyword_1_0 = new AlternativeAlias(false, false, new TokenAlias(false, false, grammarAccess.getDepClauseAccess().getDEPENDS_ONKeyword_0_0()), new TokenAlias(false, false, grammarAccess.getDepClauseAccess().getLessThanSignHyphenMinusKeyword_1_0()));
		match_Expression_C_FLOATParserRuleCall_1_6_or_C_INTEGERParserRuleCall_1_7_or_STRINGTerminalRuleCall_1_5 = new AlternativeAlias(false, false, new TokenAlias(false, false, grammarAccess.getExpressionAccess().getC_FLOATParserRuleCall_1_6()), new TokenAlias(false, false, grammarAccess.getExpressionAccess().getC_INTEGERParserRuleCall_1_7()), new TokenAlias(false, false, grammarAccess.getExpressionAccess().getSTRINGTerminalRuleCall_1_5()));
		match_SymAttrSpec_TermSpec_SymClassParserRuleCall_0_or_TERMKeyword_0 = new AlternativeAlias(false, false, new TokenAlias(false, false, grammarAccess.getSymAttrSpecAccess().getSymClassParserRuleCall_0()), new TokenAlias(false, false, grammarAccess.getTermSpecAccess().getTERMKeyword_0()));
		match_SymOcc_HEADKeyword_1_4_or_INHKeyword_1_2_or_SYNTKeyword_1_1_or_TAILKeyword_1_5_or_THISKeyword_1_3 = new AlternativeAlias(false, false, new TokenAlias(false, false, grammarAccess.getSymOccAccess().getHEADKeyword_1_4()), new TokenAlias(false, false, grammarAccess.getSymOccAccess().getINHKeyword_1_2()), new TokenAlias(false, false, grammarAccess.getSymOccAccess().getSYNTKeyword_1_1()), new TokenAlias(false, false, grammarAccess.getSymOccAccess().getTAILKeyword_1_5()), new TokenAlias(false, false, grammarAccess.getSymOccAccess().getTHISKeyword_1_3()));
		match_SymOcc_IndexParserRuleCall_1_0_1_q = new TokenAlias(false, true, grammarAccess.getSymOccAccess().getIndexParserRuleCall_1_0_1());
		match_SymbolRef_IndexParserRuleCall_1_0_1_q = new TokenAlias(false, true, grammarAccess.getSymbolRefAccess().getIndexParserRuleCall_1_0_1());
		match_SymbolRef_IndexParserRuleCall_1_1_1_q = new TokenAlias(false, true, grammarAccess.getSymbolRefAccess().getIndexParserRuleCall_1_1_1());
		match_SyntUnit_DollarSignKeyword_1_0_q = new TokenAlias(false, true, grammarAccess.getSyntUnitAccess().getDollarSignKeyword_1_0());
	}
	
	@Override
	protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) {
		if(ruleCall.getRule() == grammarAccess.getC_FLOATRule())
			return getC_FLOATToken(semanticObject, ruleCall, node);
		else if(ruleCall.getRule() == grammarAccess.getC_INTEGERRule())
			return getC_INTEGERToken(semanticObject, ruleCall, node);
		else if(ruleCall.getRule() == grammarAccess.getClassRule())
			return getClassToken(semanticObject, ruleCall, node);
		else if(ruleCall.getRule() == grammarAccess.getIDRule())
			return getIDToken(semanticObject, ruleCall, node);
		else if(ruleCall.getRule() == grammarAccess.getIndexRule())
			return getIndexToken(semanticObject, ruleCall, node);
		else if(ruleCall.getRule() == grammarAccess.getSTRINGRule())
			return getSTRINGToken(semanticObject, ruleCall, node);
		else if(ruleCall.getRule() == grammarAccess.getSymClassRule())
			return getSymClassToken(semanticObject, ruleCall, node);
		return "";
	}
	
	/**
	 * C_FLOAT: INT '.' (EXT_INT | INT);
	 */
	protected String getC_FLOATToken(EObject semanticObject, RuleCall ruleCall, INode node) {
		if (node != null)
			return getTokenText(node);
		return ".e-";
	}
	
	/**
	 * C_INTEGER: INT;
	 */
	protected String getC_INTEGERToken(EObject semanticObject, RuleCall ruleCall, INode node) {
		if (node != null)
			return getTokenText(node);
		return "";
	}
	
	/**
	 * Class: 'SYNT' | 'INH';
	 */
	protected String getClassToken(EObject semanticObject, RuleCall ruleCall, INode node) {
		if (node != null)
			return getTokenText(node);
		return "SYNT";
	}
	
	/**
	 * terminal ID  		: '^'?('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*;
	 */
	protected String getIDToken(EObject semanticObject, RuleCall ruleCall, INode node) {
		if (node != null)
			return getTokenText(node);
		return "";
	}
	
	/**
	 * Index: '[' C_INTEGER ']';
	 */
	protected String getIndexToken(EObject semanticObject, RuleCall ruleCall, INode node) {
		if (node != null)
			return getTokenText(node);
		return "[]";
	}
	
	/**
	 * terminal STRING	: 
	 * 			'"' ( '\\' ('b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\\') | !('\\'|'"') )* '"' |
	 * 			"'" ( '\\' ('b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\\') | !('\\'|"'") )* "'"
	 * 		;
	 */
	protected String getSTRINGToken(EObject semanticObject, RuleCall ruleCall, INode node) {
		if (node != null)
			return getTokenText(node);
		return "\"\"";
	}
	
	/**
	 * SymClass: ('TREE' | 'CLASS')? 'SYMBOL';
	 */
	protected String getSymClassToken(EObject semanticObject, RuleCall ruleCall, INode node) {
		if (node != null)
			return getTokenText(node);
		return "SYMBOL";
	}
	
	@Override
	protected void emitUnassignedTokens(EObject semanticObject, ISynTransition transition, INode fromNode, INode toNode) {
		if (transition.getAmbiguousSyntaxes().isEmpty()) return;
		List<INode> transitionNodes = collectNodes(fromNode, toNode);
		for (AbstractElementAlias syntax : transition.getAmbiguousSyntaxes()) {
			List<INode> syntaxNodes = getNodesFor(transitionNodes, syntax);
			if(match_AttrComp_CHAINSTARTKeyword_2_0_q.equals(syntax))
				emit_AttrComp_CHAINSTARTKeyword_2_0_q(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_AttrDef_ClassParserRuleCall_3_q.equals(syntax))
				emit_AttrDef_ClassParserRuleCall_3_q(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_AttrSpec_ClassParserRuleCall_4_q.equals(syntax))
				emit_AttrSpec_ClassParserRuleCall_4_q(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_Computation_BOTTOMUPKeyword_1_q.equals(syntax))
				emit_Computation_BOTTOMUPKeyword_1_q(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_DepClause_DEPENDS_ONKeyword_0_0_or_LessThanSignHyphenMinusKeyword_1_0.equals(syntax))
				emit_DepClause_DEPENDS_ONKeyword_0_0_or_LessThanSignHyphenMinusKeyword_1_0(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_Expression_C_FLOATParserRuleCall_1_6_or_C_INTEGERParserRuleCall_1_7_or_STRINGTerminalRuleCall_1_5.equals(syntax))
				emit_Expression_C_FLOATParserRuleCall_1_6_or_C_INTEGERParserRuleCall_1_7_or_STRINGTerminalRuleCall_1_5(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_SymAttrSpec_TermSpec_SymClassParserRuleCall_0_or_TERMKeyword_0.equals(syntax))
				emit_SymAttrSpec_TermSpec_SymClassParserRuleCall_0_or_TERMKeyword_0(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_SymOcc_HEADKeyword_1_4_or_INHKeyword_1_2_or_SYNTKeyword_1_1_or_TAILKeyword_1_5_or_THISKeyword_1_3.equals(syntax))
				emit_SymOcc_HEADKeyword_1_4_or_INHKeyword_1_2_or_SYNTKeyword_1_1_or_TAILKeyword_1_5_or_THISKeyword_1_3(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_SymOcc_IndexParserRuleCall_1_0_1_q.equals(syntax))
				emit_SymOcc_IndexParserRuleCall_1_0_1_q(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_SymbolRef_IndexParserRuleCall_1_0_1_q.equals(syntax))
				emit_SymbolRef_IndexParserRuleCall_1_0_1_q(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_SymbolRef_IndexParserRuleCall_1_1_1_q.equals(syntax))
				emit_SymbolRef_IndexParserRuleCall_1_1_1_q(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_SyntUnit_DollarSignKeyword_1_0_q.equals(syntax))
				emit_SyntUnit_DollarSignKeyword_1_0_q(semanticObject, getLastNavigableState(), syntaxNodes);
			else acceptNodes(getLastNavigableState(), syntaxNodes);
		}
	}

	/**
	 * Syntax:
	 *     'CHAINSTART'?
	 */
	protected void emit_AttrComp_CHAINSTARTKeyword_2_0_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     Class?
	 */
	protected void emit_AttrDef_ClassParserRuleCall_3_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     Class?
	 */
	protected void emit_AttrSpec_ClassParserRuleCall_4_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     'BOTTOMUP'?
	 */
	protected void emit_Computation_BOTTOMUPKeyword_1_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     '<-' | 'DEPENDS_ON'
	 */
	protected void emit_DepClause_DEPENDS_ONKeyword_0_0_or_LessThanSignHyphenMinusKeyword_1_0(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     STRING | C_INTEGER | C_FLOAT
	 */
	protected void emit_Expression_C_FLOATParserRuleCall_1_6_or_C_INTEGERParserRuleCall_1_7_or_STRINGTerminalRuleCall_1_5(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     SymClass | 'TERM'
	 */
	protected void emit_SymAttrSpec_TermSpec_SymClassParserRuleCall_0_or_TERMKeyword_0(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     'SYNT' | 'THIS' | 'HEAD' | 'TAIL' | 'INH'
	 */
	protected void emit_SymOcc_HEADKeyword_1_4_or_INHKeyword_1_2_or_SYNTKeyword_1_1_or_TAILKeyword_1_5_or_THISKeyword_1_3(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     Index?
	 */
	protected void emit_SymOcc_IndexParserRuleCall_1_0_1_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     Index?
	 */
	protected void emit_SymbolRef_IndexParserRuleCall_1_0_1_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     Index?
	 */
	protected void emit_SymbolRef_IndexParserRuleCall_1_1_1_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     '$'?
	 */
	protected void emit_SyntUnit_DollarSignKeyword_1_0_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
}
